﻿<Page x:Class="Stankovita.Program.Pages.View"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Stankovita.Program.Pages"
      mc:Ignorable="d" 
      d:DesignHeight="650" d:DesignWidth="850"
      Title="View">

    <Grid Background="WhiteSmoke">

        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <!--Метка для выбора элемента-->
        <Label Grid.Row="1"
               Content="* Выберите таблицу нажав по кнопке сверху"
               Foreground="#FF4CB034"
               FontSize="30"
               FontFamily="Calibri"
               HorizontalAlignment="Center"
               VerticalAlignment="Top"/>
        <Image Grid.Row="1"
               Source="/Resources/logo.png"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Height="80"/>
        
        <!--Вернуться в режим подключения-->
        <Button Name="BackBtn"
                Style="{DynamicResource ButtonStyle}"
                Content="Назад"
                VerticalAlignment="Center"
                HorizontalAlignment="Left"
                FontSize="20"
                Margin="5 0 0 0"
                Width="70" 
                Click="BackBtn_Click"/>

        <!--Имя пользователя в Label-->
        <Label Name="NameUserLb"
               Foreground="Black"
               Content="Имя пользователя"
               VerticalContentAlignment="Center"
               FontSize="15"
               Margin="5"
               BorderBrush="Black"
               BorderThickness="1"
               HorizontalAlignment="Right"/>

        <!--Кнопка для отображения страницы логов-->
        <Button Name="OpenUsersLogBtn"
                Style="{DynamicResource ButtonStyle}"
                Visibility="Hidden"
                Content="Логи"
                BorderThickness="2"
                FontSize="15"
                VerticalAlignment="Center"
                HorizontalAlignment="Center"
                Height="30"
                Margin="0 0 300 0"
                Click="OpenUsersLog_Click"/>

        <!--#region КНОПКИ ПЕРЕХОДА МЕЖДУ ТАБЛИЦАМИ-->
        <WrapPanel Orientation="Horizontal"
                   HorizontalAlignment="Center">
            <Button Name="SwitchOnManufacturesTableBtn"
                    BorderThickness="2"
                    IsEnabled="False"
                    Content="СТАНКИ"
                    FontSize="16"
                    Padding="5"
                    Margin="3"
                    Click="SwitchOnManufacturesTableBtn_Click">
                <Button.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </Button.Resources>
            </Button>
            <Button Name="SwitchOnOrdersTableBtn"
                    IsEnabled="False"
                    BorderThickness="2"
                    Content="ЗАКАЗЫ"
                    FontSize="16"
                    Padding="5"
                    Margin="3"
                    Click="SwitchOnOrdersTableBtn_Click">
                <Button.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </Button.Resources>
            </Button>
            <Button Name="SwitchOnCustomersTableBtn"
                    IsEnabled="False"
                    BorderThickness="2"
                    Content="КЛИЕНТЫ"
                    FontSize="16"
                    Padding="5"
                    Margin="3"
                    Click="SwitchOnCustomersTableBtn_Click">
                <Button.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </Button.Resources>
            </Button>
        </WrapPanel>
        <!--#endregion КНОПКИ ПЕРЕХОДА МЕЖДУ ТАБЛИЦАМИ-->

        <!--#region ТАБЛИЦА СТАНКИ-->
        <Grid Name="GridTableManufactures"
              Grid.Row="1"
              Visibility="Hidden">

            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="150"/>
            </Grid.RowDefinitions>

            <!--Таблица с данными-->
            <DataGrid Name="dGridManufactures"
                      Margin="5"
                      AutoGenerateColumns="False"
                      IsReadOnly="True"
                      BorderBrush="#FF4CB034"
                      BorderThickness="3"
                      SelectionMode="Single">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Название"
                                        Width="Auto"
                                        Binding="{Binding nameMachine}"/>
                    <DataGridTemplateColumn Header="Фото">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Image Width="80"
                                       Height="80"
                                       VerticalAlignment="Center"
                                       Source="{Binding photo}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Дата производства"
                                        Width="Auto"
                                        Binding="{Binding dateProd}"/>
                    <DataGridTextColumn Header="Стоимость"
                                        Width="Auto"
                                        Binding="{Binding cost}"/>
                    <DataGridTextColumn Header="Скидка"
                                        Width="Auto"
                                        Binding="{Binding discount}"/>
                    <DataGridTemplateColumn x:Name="EditorMachineBtn"
                                            Width="Auto"
                                            Visibility="Hidden">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Name="EditMachineBtn"
                                    FontSize="20"
                                    Width="230"
                                    Height="40"
                                    Content="Редактировать запись"
                                    Click="EditMachineBtn_Click"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>

                <DataGrid.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </DataGrid.Resources>
                
            </DataGrid>
            
            <!--Кнопка добавления записи-->
            <Button Name="AddMachineBtn"
                    Grid.Row="1"
                    Visibility="Hidden"
                    Style="{DynamicResource ButtonStyle}"
                    FontSize="20"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Width="170"
                    Height="40"
                    Content="Добавить станок"
                    Margin="5 0 0 0"
                    Click="AddMachineBtn_Click"/>

            <!--Кнопка удаления-->
            <Button Name="DeleteMachineBtn"
                    Grid.Row="1"
                    Visibility="Hidden"
                    Style="{DynamicResource ButtonStyle}"                
                    FontSize="20"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    Width="160"
                    Height="40"
                    Content="Удалить станок"
                    Margin="0 0 5 0"
                    Click="DeleteMachineBtn_Click"/>

            <!--Поиск данных секции-->
            <StackPanel Name="SearchMachineSP"
                        Grid.Row="2"
                        Width="200"
                        Orientation="Horizontal"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Margin="0 5 40 0">
                <TextBlock Text="Поиск"
                           VerticalAlignment="Center"
                           Foreground="Black"
                           Margin="30 0 7 0"/>
                <TextBox Name="SearchMachineTxb"
                         VerticalContentAlignment="Center"
                         Height="25"
                         Width="120"
                         TextChanged="SearchMachineTxb_TextChanged"/>
            </StackPanel>

            <!--Фильтрация станков по скидке-->
            <StackPanel Name="FilterDiscountSP"
                        Grid.Row="1"
                        Width="187"
                        Orientation="Horizontal"
                        VerticalAlignment="Center"
                        Margin="0 0 0 40">
                <TextBlock Text="Скидка"
                           Foreground="Black"
                           VerticalAlignment="Center"
                           Margin="0 0 5 0"/>
                <ComboBox Name="FilterDiscountCmbx"
                          Height="25"
                          Width="120"
                          VerticalContentAlignment="Center"
                          SelectionChanged="FilterDiscountCmbx_SelectionChanged"/>
            </StackPanel>

        </Grid>
        <!--#endregion ТАБЛИЦА СТАНКОВ-->
        
        <!--#region ТАБЛИЦА ЗАКАЗОВ-->
        <Grid Name="GridTableOrders"
              Grid.Row="1"
              Visibility="Hidden">

            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="150"/>
            </Grid.RowDefinitions>

            <!--Таблица с данными-->
            <DataGrid Name="dGridOrders"
                      Margin="5"
                      AutoGenerateColumns="False"
                      IsReadOnly="True"
                      BorderBrush="#FF4CB034"
                      BorderThickness="3"
                      SelectionMode="Extended">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Станок"
                                        Width="Auto"
                                        Binding="{Binding Manufactures.nameMachine}"/>
                    <DataGridTextColumn Header="Заказчик"
                                        Width="Auto"
                                        Binding="{Binding Customers.nameOrganiz}"/>
                    <DataGridTextColumn Header="Дата заказа"
                                        Width="Auto"
                                        Binding="{Binding dateOrder}"/>
                    <DataGridTextColumn Header="Количество"
                                        Width="Auto"
                                        Binding="{Binding amount}"/>
                    <DataGridTemplateColumn x:Name="EditorOrderBtn"
                                            Width="Auto"
                                            Visibility="Hidden">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Name="EditOrderBtn"
                                    FontSize="20"
                                    Width="230"
                                    Height="40"
                                    Content="Редактировать запись"
                                    Click="EditOrderBtn_Click"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>

                <DataGrid.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </DataGrid.Resources>

            </DataGrid>

            <!--Кнопка добавления-->
            <Button Name="AddOrderBtn"
                    Grid.Row="1"
                    Visibility="Hidden"
                    Style="{DynamicResource ButtonStyle}"
                    FontSize="20"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Width="170"
                    Height="40"
                    Content="Добавить заказ"
                    Click="AddOrderBtn_Click"/>

            <!--Кнопка удаления-->
            <Button Name="DeleteOrderBtn"
                    Grid.Row="1"
                    Visibility="Hidden"
                    Style="{DynamicResource ButtonStyle}"                
                    FontSize="20"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    Width="160"
                    Height="40"
                    Content="Удалить заказ"
                    Margin="0 0 5 0"
                    Click="DeleteOrderBtn_Click"/>
        </Grid>
        <!--#endregion ТАБЛИЦА ЗАКАЗОВ-->

        <!--#region ТАБЛИЦА ЗАКАЗЧИКОВ-->
        <Grid Name="GridTableCustomers"
                  Grid.Row="1"
                  Visibility="Hidden">

            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="150"/>
            </Grid.RowDefinitions>

            <!--Таблица с данными-->
            <DataGrid Name="dGridCustomers"
                      Margin="5"
                      AutoGenerateColumns="False"
                      IsReadOnly="True"
                      BorderBrush="#FF4CB034"
                      BorderThickness="3"
                      SelectionMode="Single">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Название организации"
                                        Width="Auto"
                                        Binding="{Binding nameOrganiz}"/>
                    <DataGridTextColumn Header="Логин"
                                        Width="Auto"
                                        Binding="{Binding login}"/>
                    <DataGridTextColumn Header="Почта"
                                        Width="Auto"
                                        Binding="{Binding email}"/>
                </DataGrid.Columns>

                <DataGrid.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius" Value="5"/>
                    </Style>
                </DataGrid.Resources>

            </DataGrid>

            <!--Кнопка удаления-->
            <Button Name="DeleteCustomerBtn"
                    Grid.Row="1"
                    Visibility="Hidden"
                    Style="{DynamicResource ButtonStyle}"                
                    FontSize="20"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Width="170"
                    Height="40"
                    Content="Удалить заказчика"
                    Margin="0 0 5 0"
                    Click="DeleteCustomerBtn_Click"/>
            
            <!--Поиск записи-->
            <StackPanel Name="SearchOrganizSP"
                        Grid.Row="2"
                        Width="200"
                        Orientation="Horizontal"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Margin="0 5 40 0">
                <TextBlock Text="Поиск"
                           VerticalAlignment="Center"
                           Foreground="Black"
                           Margin="30 0 7 0"/>
                <TextBox Name="SearchOrganizTxb"
                         VerticalContentAlignment="Center"
                         Height="25"
                         Width="120"
                         TextChanged="SearchOrganizTxb_TextChanged"/>
            </StackPanel>

        </Grid>
        <!--#region ТАБЛИЦА ЗАКАЗЧИКОВ-->

    </Grid>
</Page>
